﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _13.Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = "C# is not C+, not PHP and not Delphi!";
            StringBuilder text1 = new StringBuilder();
            MatchCollection words = Regex.Matches(text, @"[^\.?!,\s]+");
            Match a = Regex.Match(text, @"[^\.?!,\s]+");
            int k = 0;
            for (int i = 0; i < text.Length; i++)
            {

                if (Char.IsLetter(text[i]))
                {
                    text1.Append(words[words.Count - 1 - k]);
                    k++;
                }
                else
                {
                    text1.Append(text[i]);
                }
                if (Char.IsLetter(text[i]))
                {
                    i += a.Length - 1;
                    a = a.NextMatch();
                }
            }
            Console.WriteLine(text1);


        }
    }
}
